﻿using AbpApplication.InPut;
using NewWms.Apiservice;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Automation.Text;

namespace NewWms.ViewModels.DialogsModel
{
    public class CreateMaterialPropertyDialogModel : BindableBase, IDialogAware
    {


        private readonly IBaseService baseService;

        public DelegateCommand<string> Command { get; set; }


        public CreateMaterialPropertyDialogModel()
        {
            Command = new DelegateCommand<string>(Method);
            baseService = new BaseService();
            InPut_BaseService14 = new InPut_BaseService14();
        }

        public async void Method(string obj)
        {
            switch (obj)
            {
                case "CloseDialog": RequestClose?.Invoke(null); break;
                case "CreateMaterialProperty": CreateMaterialProperty(); break;
            }
        }

        private InPut_BaseService14 inPut_BaseService14;
        public InPut_BaseService14 InPut_BaseService14
        {
            get { return inPut_BaseService14; }
            set { inPut_BaseService14 = value;RaisePropertyChanged(); }
        }


        private async void CreateMaterialProperty()
        {

        bool res=    await baseService.CreateMaterialProperty(InPut_BaseService14);
            if (res)
            {
                RequestClose?.Invoke(null);
            }
          
        }







        public string Title { get; set; } = "新加基础物料";
        public event Action<IDialogResult> RequestClose;
        public bool CanCloseDialog()
        {
            return true;
        }
        public void OnDialogClosed()
        {
           
        }
        public void OnDialogOpened(IDialogParameters parameters)
        {
           
        }
    }
}
